package org.example;

import com.google.inject.Binder;
import com.google.inject.Module;

import static io.airlift.configuration.ConfigBinder.configBinder;
import static io.airlift.http.server.HttpServerBinder.httpServerBinder;
import static io.airlift.jaxrs.JaxrsBinder.jaxrsBinder;
import static org.weakref.jmx.guice.ExportBinder.newExporter;

public class ServiceModule
        implements Module
{
    @Override
    public void configure(Binder binder)
    {
        //rest
        jaxrsBinder(binder).bind(ServiceResource.class);
        //static resouce
        httpServerBinder(binder).bindResource("/", "webapp").withWelcomeFile("index.html");
        // 配置
        configBinder(binder).bindConfig(ServiceConfig.class);
        // jmx
        newExporter(binder).export(ServiceResource.class).withGeneratedName();
    }
}
